import React from "react";
interface ClickFunc {
  (): void;
}
type Prop = {
  name: string;
  size?: number;
  color?: string;
  onClick: ClickFunc;
  stop: boolean;
};
function Icon(props: Prop) {
  return (
    <i
      className={"iconfont icon-" + props.name}
      style={{ fontSize: props.size, color: props.color }}
      onClick={(e) => {
        props.onClick();
        if (props.stop) {
          e.stopPropagation();
        }
      }}
    />
  );
}
// prop的默认值
Icon.defaultProps = {
  size: 16,
  color: "#333",
  onClick: () => {},
  stop: false,
};
export default Icon;
